﻿using System;
using System.Collections;
using System.Collections.Generic;
using Me.Prettyprint.Cassandra.Connection;
using Me.Prettyprint.Cassandra.Model.Thrift;
using Me.Prettyprint.Cassandra.Serializers;
using Me.Prettyprint.Cassandra.Service;
using Me.Prettyprint.Cassandra.Utils;
using Me.Prettyprint.Hector.Api;
using Me.Prettyprint.Hector.Api.Beans;
using Me.Prettyprint.Hector.Api.Query;
using Org.Apache.Cassandra.Thrift;

namespace Me.Prettyprint.Cassandra.Model
{
    /// <summary>
    /// Batch mutate will send multiple mutation commands to Cassandra in one call.
    /// </summary>
    /// <typeparam name="K"></typeparam>
    public class BatchMutateOperation<K> : Operation<object>
    {
        public BatchMutateOperation(OperationType opType)
            : base(opType)
        {
        }
        public BatchMutateOperation(OperationType opType, BatchMutation<K> mutations)
            : base(opType)
        {
            Mutations = mutations;
        }
        public BatchMutation<K> Mutations
        {
            get;
            set;
        }
        public override object Execute(Org.Apache.Cassandra.Thrift.Cassandra.Client cassandra)
        {
            cassandra.batch_mutate(Mutations.ConvertMutationMap(), ThriftConverter.consistencyLevel(ConsistencyLevelPolicy.Get(OperationType)));
            return null;
        }
    }
}
